
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.Shell;
using EnvDTE;

namespace WebAppUploader
{
    /// <summary>
    /// Interaction logic for UploadToIISControl.xaml
    /// </summary>
    public partial class UploadToIISControl : UserControl
    {
        private ProjectSyncModel Model = new ProjectSyncModel();

        public UploadToIISControl()
        {
            InitializeComponent();
        }

        public UploadToIISControl(VSUploaderToolWindow owner)
        {
            this.Owner = owner;
            InitializeComponent();

            this.DataContext = Model;

            this.Loaded += new RoutedEventHandler(UploadToIISControl_Loaded);
            this.Unloaded += new RoutedEventHandler(UploadToIISControl_Unloaded);
			showList.SelectedIndex = 0;
        }

        void UploadToIISControl_Unloaded(object sender, RoutedEventArgs e)
        {
            Model.Dispose();
        }

        

        void UploadToIISControl_Loaded(object sender, RoutedEventArgs e)
        {
            System.IServiceProvider sp = Owner.Package as IServiceProvider;
            Model.ServiceProvider = sp;
            Model.DTE = (DTE)sp.GetService(typeof(DTE));
            Model.Load();
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")]
        private void button1_Click(object sender, RoutedEventArgs e)
        {
        }

        public VSUploaderToolWindow Owner { get; set; }

		private void showList_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			if (showList.SelectedIndex == 0) {
				fileListView.Items.Filter = x => (x as ProjectFileModel).Dirty;
				return;
			}
			fileListView.Items.Filter = x => true;
		}
    }
}
